$(window).resize(function(){
    "use strict";
    //Cufon.refresh();
    });

$(document).ready(function() {
    "use strict";
    $().UItoTop({
        easingType: 'easeOutQuart'
    });
	
    if (jQuery('.container_12').width() === 960) {
        $('.portfolio-link').hover(
            function(){
var
                    Height,
                    CoverFull,
                    BlockPad;
                Height=$(this).height();
                CoverFull=$(this).find('.portfolio-cover .cover-pad').outerHeight();
                BlockPad=(Height-CoverFull)/2;
                $(this).find('.portfolio-cover')
                .css({
                    'height':(Height-BlockPad),
                    'padding-top':BlockPad
                })
                .stop()
                .animate({
                    left:0
                }, 200);
            },
            function(){
                $(this).find('.portfolio-cover').stop().animate({
                    left:'-100%',
                    height:'auto'
                }, 200);
            }
            );
        $('.hover-links ').hover(
            function(){
              var Height;
                Height=(($(this).height())-50)/2;
                $(this).find('.hidden-links').css({
                    'left':($(this).width())/2-52
                }).stop().animate({
                    top:Height
                }, 200);
            },
            function(){
                $(this).find('.hidden-links').stop().animate({
                    top:-50
                }, 200);
            }
            );
    }
    getTwitters('twitter', { 
        id: 'envato', 
        count: 3, 
        enableLinks: true, 
        ignoreReplies: true, 
        clearContents: true,
        template: '<div class="tweet-body"><img src="%user_profile_image_url%" alt="" />%user_name%%text%" <a href="http://twitter.com/%user_screen_name%/statuses/%id_str%/">%time%</a></div>'
    });
    
    getTwitters('twitter2', { 
        id: 'envato', 
        count: 2, 
        enableLinks: true, 
        ignoreReplies: true, 
        clearContents: true,
        template: '<div class="tweet-body"><img src="%user_profile_image_url%" alt="" />%user_name%%text%" <a href="http://twitter.com/%user_screen_name%/statuses/%id_str%/">%time%</a></div>'
    });
   
    $('#flickrImages').jflickrfeed({
        limit: 9,
        qstrings: {
            id: '79971593@N07'
        },
        itemTemplate: '<a href="{{image_b}}" target="_blank"><img src="{{image_s}}" alt="{{title}}" /></a>'
    });
	
    $('#flickrImages2').jflickrfeed({
        limit: 6,
        qstrings: {
            id: '79971593@N07'
        },
        itemTemplate: '<a href="{{image_b}}" target="_blank"><img src="{{image_s}}" alt="{{title}}" /></a>'
    });
	
});

$(function(){
    "use strict";
    // IPad/IPhone
    var viewportmeta = document.querySelector && document.querySelector('meta[name="viewport"]'),
    ua = navigator.userAgent,
 
    gestureStart = function () {
        viewportmeta.content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
    },
 
    scaleFix = function () {
        if (viewportmeta && /iPhone|iPad/.test(ua) && !/Opera Mini/.test(ua)) {
            viewportmeta.content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
            document.addEventListener("gesturestart", gestureStart, false);
        }
    };
    scaleFix();

    // Menu Android
    var userag = navigator.userAgent.toLowerCase();
    var isAndroid = userag.indexOf("android") > -1; 
    if(isAndroid) {
        $('.sf-menu').responsiveMenu({
            autoArrows:true
        });
    }
    // Slider
    $('#slides').slides({
        effect: 'fade',
        fadeSpeed:700,
        preload: true,
        play: 700000,
        pause: 700000,
        generateNextPrev: true,
        generatePagination: true,
        crossfade: true,
        hoverPause: true,
        animationStart: function(current){
            $('.caption').animate({
                opacity:0
            });
            if (window.console && console.log) {
                console.log('animationStart on slide: ', current);
            }
        },
        animationComplete: function(current){
            $('.caption').animate({
                opacity:1
            });
            if (window.console && console.log) {
                console.log('animationComplete on slide: ', current);
            }
        },
        slidesLoaded: function() {
            $('.caption').animate({
                opacity:1
            });
        }
    });
});